package main

import "fmt"

type Person struct {
	Name string
	Age int
	Sex string
	height int
}

func (p Person) PrintInfo() {
	fmt.Printf("Name: %s, Age: %d, Sex: %s, Height: %d\n", p.Name, p.Age, p.Sex, p.height)
}

func (p *Person) SetInfo(name string, age int){ // 修改时需要指针
	p.Name = name
	p.Age = age
}

func main() {
	var p1 = Person{
		Name: "张三",
		Age: 25,
		Sex: "男",
	}
	p1.PrintInfo()

	var p2 = Person{
		Name: "迪蒙",
		Age: 29,
		Sex: "男",
	}
	p2.PrintInfo()
	p2.SetInfo("唐", 27)
	p2.PrintInfo()
}